package com.example.demo.controller;

import com.example.demo.model.BookInfo;
import com.example.demo.service.BookService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@RestController
@RequestMapping("/book")
public class BookController {


    @Autowired
    private BookService bookService;



    @RequestMapping("/getBookListByPage")
    public List<BookInfo> getBookList(){
        List<BookInfo> result = bookService.getBookList();
        for (BookInfo bookInfo : result) {
            bookInfo.toString();
        }
        return result;
    }



    @RequestMapping("/addBook")
    public Boolean addBook(BookInfo bookInfo){
        return true;
    }


    @RequestMapping("/updateBook")
    public Boolean updateBook(BookInfo bookInfo){
        return true;
    }

    @RequestMapping("/getBook")
    public BookInfo getBook(Integer id){
        BookInfo book = new BookInfo();
        book.setId(id);
        book.setBookName("Java从入门到放弃");
        book.setAuthor("老马啸西风");
        book.setPrice(100.0);
        book.setPublish("人民邮电出版社");
        book.setStatusCN("已借出");
        book.setCount(50);
        return book;

    }
}
